home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 9
/
FM Towns Free Software Collection 9.iso
/
t_os
/
tool
/
pdriver
/
psub.c
< prev
Wrap
Text File
|
1994-11-16
|
8KB
|
545 lines
#include"pdriver.h"
int addstrings( const char *s, char *t )
{
int i;
i = 0;
while( *s )
{
*t++ = *s++;
i++;
}
return i;
}
int cmpstrings( const char *s, const char *t )
{
while( *t )
{
if( *s++ != *t++ )
return 0;
}
return 1;
}
int printStrings( int n, char *p )
{
int i,e;
/* FILE *fp;
fp = fopen( "i:\\debug.bin", "ab" );*/
if( n )
{
for( i=0; i<n; i++ )
{
while( e = PRN_putc( *(p+i) ) )
{
if( printReady( e ) )
{
end_();
exit(0);
}
}
/* fputc( *(p+i), fp );*/
}
}
else
{
while( *p )
{
while( e = PRN_putc( *p ) )
{
if( printReady( e ) )
{
end_();
exit(0);
}
}
/* fputc( *p, fp );*/
p++;
}
}
/* fclose( fp );*/
return 0;
}
int printKanji( char *p )
{
union
{
unsigned short int sjis;
char c[2];
} moji;
int jis,e;
char mode;
mode = ' ';
moji.c[1] = *p;
while( moji.c[1] )
{
moji.c[1] = *p++;
D_print((" %2x ",(moji.c[1] & 0xff)));
if( (((unsigned int)moji.c[1]&0xff)>0xe0) ||
( (((unsigned int)moji.c[1]&0xff)>0x80) &&
(((unsigned int)moji.c[1]&0xff)<0xa0) ) )
{
moji.c[0] = *p++;
D_print((" %2x ",(moji.c[0] & 0xff)));
jis = FNT_sjisToJis( (int)moji.sjis );
if( mode != 'K' )
{
mode = 'K';
while( e = printStrings( 0, scsjis ) )
{
if( printReady( e ) )
return 1;
}
}
moji.sjis = (unsigned short int)jis;
while( e = PRN_putc( moji.c[1] ) )
{
if( printReady( e ) )
return 1;
}
while( e = PRN_putc( moji.c[0] ) )
{
if( printReady( e ) )
return 1;
}
}
else
{
if( mode != 'A' )
{
mode = 'A';
while( e = printStrings( 0, scsank ) )
{
if( printReady( e ) )
return 1;;
}
}
while( e = PRN_putc( moji.c[1] ) )
{
if( printReady( e ) )
return 1;
}
}
}
return 0;
}
int search( char *p, int *i )
{
if( cmpstrings( p, "h1byte" ) ) /*半角1byte指定*/
{
*i = 6;
return 1;
}
if( cmpstrings( p, "up{" ) ) /*上付文字開始*/
{
*i = 3;
return 2;
}
if( cmpstrings( p, "down{" ) ) /*下付文字開始*/
{
*i = 5;
return 4;
}
if( cmpstrings( p, "kanjipitch(" ) ) /*漢字文字ピッチ*/
{
int j;
unsigned char n;
char *k;
k = pool;
*i = 12;
for( j=11; j<15; j++ )
{
if( *(p+j) == ')' )
{
k --;
*k += 0x50;
k ++;
*k = 0;
k ++;
*k = n;
break;
}
if( *(p+j) >= '0' && *(p+j) <= '9' )
{
n *= 10;
n += *(p+j) - 0x30;
++ *i;
*k = *(p+j) - 0x10;
k ++;
}
else
{
return 0;
}
}
return 6;
}
if( cmpstrings( p, "retpitch(" ) ) /*改行ピッチ*/
{
int j;
char *k;
unsigned char n;
k = pool;
*i = 10;
for( j=9; j<13; j++ )
{
if( *(p+j) == ')' )
{
k --;
*k += 0x50;
k ++;
*k = 0;
k ++;
*k = n;
break;
}
if( *(p+j) >= '0' && *(p+j) <= '9' )
{
n *= 10;
n += *(p+j) - 0x30;
++ *i;
*k = *(p+j) - 0x10;
k ++;
}
else
{
return 0;
}
}
return 8;
}
if( cmpstrings( p, "normal" ) ) /*標準*/
{
*i = 6;
if( *(p+6) = '{' )
{
++ *i;
pool[0] = 1;
}
else
pool[0] = 0;
return 10;
}
if( cmpstrings( p, "wide" ) ) /*横倍*/
{
*i = 4;
if( *(p+4) = '{' )
{
++ *i;
pool[0] = 1;
}
else
pool[0] = 0;
return 11;
}
if( cmpstrings( p, "tall" ) ) /*縦倍*/
{
*i = 4;
if( *(p+4) = '{' )
{
++ *i;
pool[0] = 1;
}
else
pool[0] = 0;
return 12;
}
if( cmpstrings( p, "large" ) ) /*縦横倍*/
{
*i = 5;
if( *(p+5) = '{' )
{
++ *i;
pool[0] = 1;
}
else
pool[0] = 0;
return 13;
}
if( cmpstrings( p, "halftall" ) ) /*縦半分*/
{
*i = 8;
if( *(p+8) = '{' )
{
++ *i;
pool[0] = 1;
}
else
pool[0] = 0;
return 14;
}
if( cmpstrings( p, "halfwide" ) ) /*横半分*/
{
*i = 8;
if( *(p+8) = '{' )
{
++ *i;
pool[0] = 1;
}
else
pool[0] = 0;
return 15;
}
if( cmpstrings( p, "h_t_wide" ) ) /*縦半分横倍*/
{
*i = 8;
if( *(p+8) = '{' )
{
++ *i;
pool[0] = 1;
}
else
pool[0] = 0;
return 16;
}
if( cmpstrings( p, "h_w_tall" ) ) /*縦倍横半分*/
{
*i = 8;
if( *(p+8) = '{' )
{
++ *i;
pool[0] = 1;
}
else
pool[0] = 0;
return 17;
}
if( cmpstrings( p, "small" ) ) /*縦横半分*/
{
*i = 5;
if( *(p+5) = '{' )
{
++ *i;
pool[0] = 1;
}
else
pool[0] = 0;
return 18;
}
if( cmpstrings( p, "gothic" ) ) /*ゴシック*/
{
*i = 6;
if( *(p+6) = '{' )
{
++ *i;
pool[0] = 1;
}
else
pool[0] = 0;
return 19;
}
if( cmpstrings( p, "mintyo" ) ) /*明朝体*/
{
*i = 6;
if( *(p+6) = '{' )
{
++ *i;
pool[0] = 1;
}
else
pool[0] = 0;
return 20;
}
if( cmpstrings( p, "underline{" ) ) /*漢字アンダーライン指定*/
{
*i = 10;
return 21;
}
if( cmpstrings( p, "connect_on" ) ) /*罫線接続指定*/
{
*i = 10;
return 27;
}
if( cmpstrings( p, "connect_off" ) ) /*罫線接続解除*/
{
*i = 11;
return 28;
}
if( cmpstrings( p, "set_top" ) ) /*漢字縦倍上端合わせ*/
{
*i = 7;
return 29;
}
if( cmpstrings( p, "set_bottom" ) ) /*漢字縦倍下端合わせ*/
{
*i = 10;
return 30;
}
if( cmpstrings( p, "set_center" ) ) /*漢字縦倍中心合わせ*/
{
*i = 10;
return 31;
}
if( cmpstrings( p, "proportion{" ) ) /*欧文ピッチ指定*/
{
*i = 11;
return 32;
}
if( cmpstrings( p, "r_back(" ) ) /*相対水平逆タブ1/2*/
{
int j;
char *k;
k = pool;
*i = 8;
for( j=7; j<11; j++ )
{
if( *(p+j) == ')' )
{
*k = 0x6a;
k ++;
*k = 0;
break;
}
if( *(p+j) >= '0' && *(p+j) <= '9' )
{
++ *i;
*k = *(p+j);
k ++;
}
else
{
return 0;
}
}
return 37;
}
if( cmpstrings( p, "next" ) ) /*ページ印字+改ページ*/
{
*i = 4;
return 38;
}
if( cmpstrings( p, "leftmargin(" ) ) /*レフトマージン指定*/
{
int j;
char *k;
unsigned char n;
k = pool;
*i = 12;
n = 0;
for( j=11; j<15; j++ )
{
if( *(p+j) == ')' )
{
*k = 0x20;
k ++;
*k = 0x51;
k ++;
*k = 0;
k ++;
*k = n;
break;
}
if( *(p+j) >= '0' && *(p+j) <= '9' )
{
++ *i;
*k = *(p+j);
k ++;
n *= 10;
n += *(p+j) - '0';
}
else
{
return 0;
}
}
return 39;
}
if( cmpstrings( p, "net(" ) ) /*網掛け*/
{
int j;
*pool = 0;
*i = 5+1;
for( j=4; j<8; j++ )
{
if( *(p+j) == ')' )
{
if( *(p+j+1) == '{' )
break;
else
return 0;
}
if( *(p+j) >= '0' && *(p+j) <= '9' )
{
++ *i;
*pool *= 10;
*pool += *(p+j) - '0';
}
else
{
return 0;
}
}
return 40;
}
return 0;
}
int printReady( int e )
{
int ch,ec;
if( e > 6 )
e = 7;
printf( "%s\n準備が出来たら何かキーを押してください。(<a> abort)\n", errmes[e] );
KYB_clrbuf();
ch = KYB_read( 0, &ec );
if( ch == 'a' || ch == 'A' )
return 1;
return 0;
}
void bufprint( char *b )
{
while( *b++ )
{
printf( "%2x ", *b & 0xff );
}
printf("\n");
return;
}
int end_()
{
printf( "The end of プリント君. See you again!\n" );
return;
}